#ifndef _AK_AO_H_
#define _AK_AO_H_

#include "ak_global.h"

enum ao_play_status {
	AO_PLAY_STATUS_RESERVED = 0x00,
	AO_PLAY_STATUS_READY,               //ready to write to da
	AO_PLAY_STATUS_DATA_NOT_ENOUGH,     //data is not enough that ao write to da
	AO_PLAY_STATUS_PLAYING,             //data is enough to play
	AO_PLAY_STATUS_FINISHED             //play finished
};

/**
 * ak_ao_get_version - get audio out version
 * return: version string
 * notes:
 */
const char* ak_ao_get_version(void);

/**
 * ak_ao_open - open audio out device, DA
 * @param[IN]: open DA param
 * return: opened ao_handle, otherwize NULL
 * notes: sample_bits set 16 bit
 */
void* ak_ao_open(const struct pcm_param *param);

/**
 * ak_ao_send_frame - send frame to DA device
 * @ao_handle[IN]: audio out opened handle
 * @data[IN]: audio pcm data
 * @len[IN]: audio pcm data len
 * @ms[IN]: <0 block mode; =0 non-block mode; >0 wait time
 * return: real sent data len, -1 failed
 * notes:
 */
int ak_ao_send_frame(void *ao_handle, unsigned char *data, int len, long ms);

/**
 * ak_ao_clear_frame_buffer - frame buffer clean
 * @ao_handle[IN]: audio out opened handle
 * return: 0 success, -1 failed
 * notes: clean buffer after "ak_ao_open"
 */
int ak_ao_clear_frame_buffer(void *ao_handle);

/**
 * ak_ao_get_play_status - get audio play status
 * @ao_handle[in]: opened audio output handle
 * return: current audio play status
 * notes:
 */
enum ao_play_status ak_ao_get_play_status(void *ao_handle);

/**
 * ak_ao_set_play_status - set audio play status
 * @ao_handle[in]: opened audio output handle
 * @status[in]: new status
 * return: 0 success; -1 failed
 * notes:
 */
int ak_ao_set_play_status(void *ao_handle, enum ao_play_status status);

/**
 * ak_ai_set_volume - set volume
 * @ao_handle[IN]: audio out opened handle
 * @volume[IN]: new volume value, [0, 12]: 0-mute, 12-max volume
 * return: 0 success, -1 failed
 * notes:
 */
int ak_ao_set_volume(void *ao_handle, int volume);

/**
 * ak_ao_set_resample - set audio output resampling
 * @handle[IN]: audio out opened handle
 * @enable[IN]: 0 close, 1 open
 * return: 0 success, -1 failed
 */
int ak_ao_set_resample(void *ao_handle, int enable);

/**
 * ak_ao_enable_speaker - enable speaker
 * @ao_handle[IN]: audio out opened handle
 * @enable[IN]: 0 disable,1 enable
 * return: 0 success, -1 failed
 * notes:
 */
int ak_ao_enable_speaker(void *ao_handle, int enable);

/**
 * ak_ao_set_sample_rate - set new sample rate
 * @ao_handle[IN]: opened DA handle
 * @sample_rate[IN]: ao sample rate.
 * return: 0 success, -1 failed
 * notes:
 */
int ak_ao_set_sample_rate(void *ao_handle, int sample_rate);

/**
 * ak_ao_close - close audio output
 * @ao_handle[IN]: opened DA handle
 * return: 0 success, -1 failed
 * notes:
 */
int ak_ao_close(void *ao_handle);

#endif
